package com.sttk.secreconeclick.bookkeep.adapter;

import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;

import com.blankj.utilcode.util.TimeUtils;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.lzb.basic.ProviderMultiAdapter;
import com.sttk.secreconeclick.bookkeep.R;
import com.sttk.secreconeclick.bookkeep.bean.RankBean;

import org.jetbrains.annotations.NotNull;

import java.text.SimpleDateFormat;


public class RankAdapter extends ProviderMultiAdapter<RankBean> {

    private boolean isIncome;

    public RankAdapter() {
        addItemProvider(new RankItemProvider());
    }

    public void setIncome(boolean income) {
        isIncome = income;
    }

    private class RankItemProvider extends BaseItemProvider<RankBean> {
        @Override
        public int getItemViewType() {
            return ProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_rank;
        }

        @Override
        public void convert(@NotNull BaseViewHolder baseViewHolder, RankBean bean) {
            baseViewHolder.setImageResource(R.id.ivRankItemIcon, bean.getBillTypeBean().getSaveIcon());
            baseViewHolder.setText(R.id.tvRankItemName, bean.getBillTypeBean().getName());
            baseViewHolder.setText(R.id.tvRankItemPercent, bean.getPercent() + context.getString(R.string.unit_percent));
            if (isIncome) {
                baseViewHolder.setText(R.id.tvRankItemMoney, "+" + String.format("%.2f", bean.getMoney()));
            } else {
                baseViewHolder.setText(R.id.tvRankItemMoney, "-" + String.format("%.2f", bean.getMoney()));
            }
        }
    }
}
